<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>添加组合</title>
</head>
<body>

<script type="text/html" id="form">
    <div class="mainBox">
        <div class="main-container">
            <div class="main-container">
                <blockquote class="layui-elem-quote">基础信息</blockquote>
                {{# if(d.style.show_author == 1){ }}
                <div class="layui-form-item">
                    <label class="layui-form-label">
                        <text title="必填项" style="color:red;">*</text>
                        发布者名称</label>
                    <div class="layui-input-block">
                        <input type="text" name="author_name" lay-verify="required" autocomplete="off" placeholder="请输入"
                               class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <text style="color:red;">支持jpg、png，大小不超过5M，图片尺寸建议 16:9比例</text>
                    <label class="layui-form-label">
                        <text title="必填项" style="color:red;">*</text>
                        发布者头像</label>
                    <div class="layui-input-block">
                        <div class="laytpUpload"
                             data-name="author_avatar"
                             data-dir="xm_game/lineup/team/author"
                             data-accept="image"
                             data-type="ali-oss"
                             data-layVerify="required"
                             data-showChoiceBtn="false"
                        ></div>
                    </div>
                </div>
                {{# } }}
                <div class="layui-form-item">
                    <label class="layui-form-label">
                        <text title="必填项" style="color:red;">*</text>
                        组合名称</label>
                    <div class="layui-input-block">
                        <input type="text" name="team_name" lay-verify="required" autocomplete="off" placeholder="请输入"
                               class="layui-input">
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">
                        <text title="必填项" style="color:red;">*</text>
                        组合标签</label>
                    <div class="layui-input-block">
                        <div class="xmSelect"
                             data-name="team_labels"
                             data-sourceType="route"
                             data-source="/admin.basic.category/teamTree"
                             data-params='{"relation_category": "{{d.styleRelations[4]}}"}'
                             data-textField="name"
                             data-valueField="id"
                             data-sourceTree="true"
                             data-paging="true"
                             data-layVerify="required"
                             data-direction="down"
                        ></div>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label" title="组合介绍">组合介绍</label>
                    <div class="layui-input-block">
                        <textarea name="team_description" id="team_description" placeholder="请输入组合介绍"
                                  class="layui-textarea"></textarea>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">
                        基础点赞数</label>
                    <div class="layui-input-block">
                        <input type="number" name="basic_like_number"   autocomplete="off"
                               class="layui-input" >
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">
                        基础收藏数</label>
                    <div class="layui-input-block">
                        <input type="number" name="basic_collect_number"   autocomplete="off"
                               class="layui-input" >
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">
                        基础权重数</label>
                    <div class="layui-input-block">
                        <input type="number" name="basic_power_number"   autocomplete="off"
                               class="layui-input" >
                    </div>
                </div>
                {{# if(d.style.team_one_name != ""){ }}
                <blockquote class="layui-elem-quote">{{d.style.team_one_name}}</blockquote>
                {{# } }}
                {{# for(var i=0; i<(d.style.show_role_number); i++){ }}
                <div class="layui-form-item">
                    <label class="layui-form-label">
                        组合图鉴{{i+1}}</label>
                    <div class="layui-input-inline">
                        <div class="xmSelect"
                             data-name="guide_id[{{i}}]"
                             data-sourceType="route"
                             data-source="/admin.lineup.guide/index"
                             data-params='{"search_param":{"lineup_game_id":{"value":"{{d.style.lineup_game_id}}","condition":"join"},"status":{"value":1,"condition":"join"}}}'
                             data-textField="name"
                             data-valueField="id"
                             data-paging="true"
                             data-radio="true"
                             data-direction="down"
                        ></div>
                    </div>
                    {{# if(d.style.master_content_label_id!=""&&d.style.master_content_label_id!=null){ }}
                    <label class="layui-form-label">
                        图鉴标签{{i+1}}</label>
                    <div class="layui-input-inline">
                        <div class="xmSelect"
                             data-name="master_guide_label[{{i}}]"
                             data-sourceType="route"
                             data-source="/admin.basic.category/teamTree"
                             data-params='{"relation_category": "{{d.style.master_content_label_id}}"}'
                             data-textField="name"
                             data-valueField="id"
                             data-radio="true"
                             data-paging="true"
                             data-direction="down"
                        ></div>
                    </div>
                    {{# } }}
                    {{# if(d.styleRelations[2]!=undefined){ }}
                    <label class="layui-form-label">
                        关联图鉴{{i+1}}</label>
                    <div class="layui-input-inline">
                        <div class="xmSelect"
                             data-name="content_id[{{i}}]"
                             data-sourceType="route"
                             data-source="/admin.lineup.guide/content"
                             data-params='{"lineup_game_id":"{{d.style.lineup_game_id}}","label_ids":"{{d.styleRelations[2]}}"}'
                             data-textField="name"
                             data-valueField="id"
                             data-accept=""
                             data-max="{{d.style.content_number}}"
                             data-paging="true"
                             data-radio="false"
                             data-direction="down"
                        ></div>
                    </div>
                    {{# } }}
                </div>
                {{# if(d.styleRelations[3]!=undefined){ }}
                <div class="layui-form-item">
                    <label class="layui-form-label">
                        关联标签{{i+1}}</label>
                    <div class="layui-input-inline">
                        <div class="xmSelect"
                             data-name="guide_label[{{i}}]"
                             data-sourceType="route"
                             data-source="/admin.basic.category/teamTree"
                             data-params='{"relation_category": "{{d.styleRelations[3]}}"}'
                             data-textField="name"
                             data-valueField="id"
                             data-sourceTree="true"
                             data-max="{{d.style.label_number}}"
                             data-paging="true"
                             data-direction="down"
                        ></div>
                    </div>
                </div>
                {{# } }}

                {{# } }}
                {{# if(d.style.team_one_name != ""){ }}
                <blockquote class="layui-elem-quote">{{d.style.team_two_name}}</blockquote>
                {{# for(var i=0; i<(d.style.show_role_number); i++){ }}
                <div class="layui-form-item">
                    <label class="layui-form-label">
                        组合图鉴{{i+1}}</label>
                    <div class="layui-input-inline">
                        <div class="xmSelect"
                             data-name="guide_id2[{{i}}]"
                             data-sourceType="route"
                             data-source="/admin.lineup.guide/index"
                             data-params='{"search_param":{"lineup_game_id":{"value":"{{d.style.lineup_game_id}}","condition":"join"},"status":{"value":1,"condition":"join"}}}'
                             data-textField="name"
                             data-valueField="id"
                             data-paging="true"
                             data-radio="true"
                             data-direction="down"
                        ></div>
                    </div>
                    {{# if(d.style.master_content_label_id!=""&&d.style.master_content_label_id!=null){ }}
                    <label class="layui-form-label">
                        图鉴标签{{i+1}}</label>
                    <div class="layui-input-inline">
                        <div class="xmSelect"
                             data-name="master_guide_label2[{{i}}]"
                             data-sourceType="route"
                             data-source="/admin.basic.category/teamTree"
                             data-params='{"relation_category": "{{d.style.master_content_label_id}}"}'
                             data-textField="name"
                             data-valueField="id"
                             data-radio="true"
                             data-paging="true"
                             data-direction="down"
                        ></div>
                    </div>
                    {{# } }}
                    {{# if(d.styleRelations[2]!=undefined){ }}
                    <label class="layui-form-label">
                        关联图鉴{{i+1}}</label>
                    <div class="layui-input-inline">
                        <div class="xmSelect"
                             data-name="content_id2[{{i}}]"
                             data-sourceType="route"
                             data-source="/admin.lineup.guide/content"
                             data-params='{"lineup_game_id":"{{d.style.lineup_game_id}}","label_ids":"{{d.styleRelations[2]}}"}'
                             data-textField="name"
                             data-valueField="id"
                             data-accept=""
                             data-max="{{d.style.content_number}}"
                             data-paging="true"
                             data-radio="false"
                             data-direction="down"
                        ></div>
                    </div>
                    {{# } }}
                </div>
                {{# if(d.styleRelations[3]!=undefined){ }}
                <div class="layui-form-item">
                    <label class="layui-form-label">
                        关联标签{{i+1}}</label>
                    <div class="layui-input-inline">
                        <div class="xmSelect"
                             data-name="guide_label2[{{i}}]"
                             data-sourceType="route"
                             data-source="/admin.basic.category/teamTree"
                             data-params='{"relation_category": "{{d.styleRelations[3]}}"}'
                             data-textField="name"
                             data-valueField="id"
                             data-sourceTree="true"
                             data-max="{{d.style.label_number}}"
                             data-paging="true"
                             data-direction="down"
                        ></div>
                    </div>
                </div>
                {{# } }}
                {{# } }}
                {{# } }}
            </div>
        </div>
    </div>
    <div class="bottom">
        <div class="button-container">
            <button type="submit" class="laytp-btn laytp-btn-primary laytp-btn-sm" lay-submit="" lay-filter="add">
                <i class="layui-icon layui-icon-ok"></i>
                提交
            </button>
            <button type="reset" class="laytp-btn laytp-btn-sm">
                <i class="layui-icon layui-icon-refresh"></i>
                重置
            </button>
        </div>
    </div>
</script>
<form class="layui-form" lay-filter="layui-form"></form>
<script>
    if (localStorage.getItem("staticDomain")) {
        document.write("<link rel='stylesheet' href='" + localStorage.getItem("staticDomain") + "/component/layui/css/layui.css?v=" + localStorage.getItem("version") + "'>");
        document.write("<script src='" + localStorage.getItem("staticDomain") + "/component/layui/layui.js?v=" + localStorage.getItem("version") + "'><\/script>");
        document.write("<script src='" + localStorage.getItem("staticDomain") + "/component/laytp/layuiConfig.js?v=" + localStorage.getItem("version") + "'><\/script>");
        document.write("<script src='" + localStorage.getItem("staticDomain") + "/component/jquery_3.3.1.js?v=" + localStorage.getItem("version") + "'><\/script>");
        document.write("<script src='" + localStorage.getItem("staticDomain") + "/component/jquery.tablednd.js?v=" + localStorage.getItem("version") + "'><\/script>");
    } else {
        document.write("<link rel='stylesheet' href='/static/component/layui/css/layui.css?v=" + localStorage.getItem("version") + "'>");
        document.write("<script src='/static/component/layui/layui.js?v=" + localStorage.getItem("version") + "'><\/script>");
        document.write("<script src='/static/component/laytp/layuiConfig.js?v=" + localStorage.getItem("version") + "'><\/script>");
        document.write("<script src='/static/component/jquery_3.3.1.js?v=" + localStorage.getItem("version") + "'><\/script>");
        document.write("<script src='/static/component/jquery.tablednd.js?v=" + localStorage.getItem("version") + "'><\/script>");
    }
</script>
<script>
    layui.use(['laytp'], function () {
        let form = layui.form;
        let game_id = facade.getUrlParam("game_id");
        facade.ajax({
            route: "/admin.lineup.team/style",
            data: {game_id: game_id},
            successAlert: false,
            showLoading: true
        }).done(function (res) {
            if (res.code === 0) {
                layui.laytpl($("#form").html()).render(res.data, function (string) {
                    $("form").html(string);
                    layui.laytpForm.render();
                    form.render();
                });
            }
        });
        layui.form.on('submit(add)', function (data) {
            var btnAnim = layui.button.load({elem: $(this)});
            facade.ajax({
                route: '/admin.lineup.team/add?game_id=' + game_id,
                data: data.field
            }).done(function (res) {
                if (res.code === 0) {
                    parent.layui.layer.close(parent.layui.layer.getFrameIndex(window.name));//关闭当前页
                    parent.layui.table.reload("laytp-table");
                    parent.location.reload();
                }
                btnAnim.stop();
            }).fail(function () {
                btnAnim.stop();
            });
            return false;
        });
    })
</script>
</body>
</html>